﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CardInChina.Bussiness.Frontend.Models;
using CardInChina.Bussiness.Frontend.Interface;
using CardInChina.Data.Entity.Entity;

namespace CardInChina.Web.Mvc.Controllers
{
    public class PaymentController : CICBasicController
    {
        private OrderBusinessService orderbs = new OrderBusinessService();


        /// <summary>
        /// /checkout -> 准备支付
        /// </summary>
        [SessionAuthorize]
        public ActionResult Index()
        {
            var orders = new List<System.Dynamic.ExpandoObject>();

            {
                dynamic o = new System.Dynamic.ExpandoObject();
                o.Id = 1287662;
                o.Name = "魔兽世界30元点卡";
                o.Price = 77.83;
                orders.Add(o);
            }
            {
                dynamic o = new System.Dynamic.ExpandoObject();
                o.Id = 1287663;
                o.Name = "QQ10元";
                o.Price = 29.13;
                orders.Add(o);
            }
            {
                dynamic o = new System.Dynamic.ExpandoObject();
                o.Id = 1287665;
                o.Name = "奇迹50元周卡";
                o.Price = 53.63;
                orders.Add(o);
            }

            ViewBag.Orders = orders;
            ViewBag.TotalPrice = 155.48;
            return View();
        }

        /// <summary>
        /// /transaction-succeeded -> 支付完成
        /// </summary>
        [SessionAuthorize]
        public ActionResult TransSucceeded()
        {

            return View();
        }

        /// <summary>
        /// /transaction-failed -> 支付失败
        /// </summary>
        [SessionAuthorize]
        public ActionResult TransFailed()
        {

            return View();
        }

        /// <summary>
        /// /transaction-pending -> 支付挂起
        /// </summary>
        [SessionAuthorize]
        public ActionResult TransPending()
        {

            return View();
        }

        /// <summary>
        /// /checkout/{payment} -> 各种支付方式
        /// </summary>
        [SessionAuthorize]
        public ActionResult Checkout(string payment)
        {

            return View();
        }

        //        [HttpPost]
        //        [SessionAuthorize]
        //        [ValidateAntiForgeryToken]  //防止CSRF攻击 http://www.cnblogs.com/dragon_mail/archive/2011/7/10.html
        //        public ActionResult Confirm(InputOrderInfo userInput)
        //        {
        //            //TODO : verify inputOrder.GameID is nou null or empty
        //            try
        //            {
        //                string orderIndex = orderbs.CreateOrder(userInput, CustomerInfo);
        //                Order lastOrder = orderbs.GetOrderByOrderIndex(orderIndex);
        //                ViewData.Model = lastOrder;
        //            }
        //            catch (Exception ex)
        //            {
        //                string exceptionStr = "订单创建失败<br/>";
        //#if DEBUG
        //                exceptionStr += ex.ToString();
        //#endif
        //                ViewBag.Exception = exceptionStr; 
        //            }


        //            return View();
        //        }


        //        public ActionResult Confirm()
        //        { 
        //            //if get , return 410
        //            return new HttpPageExpiredResult();
        //        }

    }
}
